const {ccclass, property} = cc._decorator;

import {StateMachine} from "./LIbs/StateMachine";
 

@ccclass
export default class Main extends cc.Component {

    
    @property(cc.JsonAsset)
    configs:cc.JsonAsset = null;


    onLoad(){
        　var fsm = StateMachine.create({

                //初始化状态
        　　　　initial: 'green', 

                //内置事件
        　　　　events: [
        　　　　　　{ name: 'warn',  from: 'green',  to: 'yellow' },
        　　　　　　{ name: 'stop', from: 'yellow', to: 'red' },
        　　　　　　{ name: 'ready',  from: 'red',    to: 'yellow' },
        　　　　　　{ name: 'go', from: 'yellow', to: 'green' }
        　　　　]
        　　
        　　},this);
  
            fsm.error = (name, from, to, args, error, msg, e)=>{
                console.log("ERRO",msg)
            }

            fsm.onafterevent = function(name, from, to, args){
                console.log(name, from, to, args)
            } 

            fsm.onafterevent = function(name, from, to, args){
                console.log(name, from, to, args)
            } 


            console.log(fsm.current)
            console.log(fsm.can("warn"))
            fsm.warn("警告不能走");
            console.log(fsm.current)
            fsm.go("开始走");
            console.log(fsm.current)
           
    

            console.log(fsm.current)
    }

    start(){

    } 
  
    onRecovery(){

    }

    
    onShop(){

    }


    onLevelUp(){


    }



}
